import pysrt


def read_srt(filepath):
    subs = pysrt.open(filepath)
    return [(sub.text, srttime2second(sub.start), srttime2second(sub.end)) for sub in subs]


# srt时间 转化为秒
def srttime2second(srtTime):
    return srtTime.hours * srtTime.HOURS_RATIO / 1000 \
        + srtTime.minutes * srtTime.MINUTES_RATIO / 1000 \
        + srtTime.seconds \
        + srtTime.milliseconds / 1000


